package com.cmy.framework.mvvm.mvvm.view

import android.app.Activity
import android.os.Bundle
import com.cmy.framework.mvvm.ParameterField
import com.cmy.framework.mvvm.event.UIChangeLiveData
import com.cmy.framework_base.basics.BasicsFragment
import com.cmy.framework_base.common.loading.SimpleLoadDialogImp

/**
 * @name:
 *  BaseFragment
 * @package:
 *  com.cmy.framework.mvvm.mvvm.view
 * @date:
 *  2023/2/1615:32
 * @author
 *    cmy
 * @description
 *
 */
abstract class BaseFragment : BasicsFragment() {

    override fun setWindowConfigure() {
        super.setWindowConfigure()

        //TODO 暂时不实用弹窗显示，因为Ui反倒变得不好看，没有好的反馈意
//        registerLoadDialogView(SimpleLoadDialogImp(childFragmentManager))
    }




    /**
     * UI刷新对应的处理
     */
    protected fun registerUiChange(uiChange: UIChangeLiveData) {

        //关闭页面
        uiChange.finishEvent.observe(this, observer = {
            requireActivity().finish()
        })


        // 页面跳转
        uiChange.startActivityEvent.observe(this, observer = {
            it?.let {
                val clz = it[ParameterField.CLASS] as Activity
                val bundle = it[ParameterField.BUNDLE] as Bundle
                startActivity(clz, bundle)
            }

        })


    }

}